<template>
  <!-- 质量-质量基础-项目分部分项配置 -->
  <base-breadcrumb :title="$route.meta.title">
    <!-- 搜索 -->
    <searchData :searchData="searchArr" @search="search"></searchData>
    <!-- 表格 -->
    <a-card :bordered="false">
      <!-- <title-name :title="$route.meta.title"></title-name> -->
      <!-- 表格 -->
      <list-table
        ref="table"
        tableLayout="fixed"
        size="default"
        rowKey="id"
        :columns="columns"
        :request="loadData"
        :isScrollX="false"
        :page-keys="['pageNo', 'pageSize', 'totalSize']"
        :alert="true"
        show-size-changer
        show-quick-jumper
        showPagination="auto"
      >
      <a-button
        slot="prefix"

        class="mb12"
        icon="plus"
        type="primary"
        @click="handleManage(2)"
        v-btnPermission="'qm_028_02_add_01'"
      >
        新增
      </a-button>
        <template slot="action" slot-scope="text, record">
          <a @click="handleManage(0, record)"  v-btnPermission="'qm_028_02_loo_03'">查看</a>
          <a-divider type="vertical" v-btnPermission="'qm_028_02_edi_02'"/>
          <a @click="handleManage(1, record)" v-btnPermission="'qm_028_02_edi_02'">编辑</a>
        </template>
      </list-table>
    </a-card>
  </base-breadcrumb>
</template>

<script>
import { getQueryProjectBind, } from '@/api/quality/projectDivision' // api
import OrgTreeSelect from '@/components/OrgTreeSelect'
import BasePage from '@/views/basePage' // 基础配置

const columns = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    }
  },
  { title: '分公司', dataIndex: 'implUnit3Name' },
  { title: '项目名称', dataIndex: 'abbreviation' },
  { title: '操作', dataIndex: 'action', align: 'center', scopedSlots: { customRender: 'action' } }
]
export default {
  name: 'a' + Date.now(),
  extends: new BasePage(),
  components: {
  },
  data() {
    this.columns = columns
    return {
      queryParam: {}, // 查询参数
      loadData: async (parameter) => {
        let that = this
        that.queryParam.isBind = 1;
        const requestParameters = Object.assign({}, parameter, { query: that.queryParam })
        return getQueryProjectBind(requestParameters).then((res) => {
          return res
        })
      } //汇总
    }
  },
   computed:{
      searchArr() {
        return [
         // 搜索框
         {
          name: '所属单位',
          valueKey: 'searchQuery',
          type: OrgTreeSelect,
        },
        ]
      }
    },
  methods: {
    // 操作栏
    handleManage(type, record) {
      let query = {}
      if (record && record.projectId) {
        query.projectId = record.projectId
      }
      query.editModel =type
      this.$router.push({
        name: 'updateProjectDivision',
        query
      })
    },
    // 搜索
    search(value) {
      console.log(value,'value')
    this.queryParam = { ...value }
      this.$refs.table.refresh(true)
    },
  },
  created() {}
}
</script>
<style lang="less" scoped>
@deep: ~'>>>';
.pint {
  @{deep} .button_right {
    display: inline-block !important;
  }
}
</style>
